Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clock: Introduce PSR-20 Clock Service as src/Data type #4004

Merged

Conversation

mjansenDatabay
Copy link
Contributor

@mjansenDatabay mjansenDatabay commented Feb 5, 2022

With this PR I would like to introduce a PSR-20 compliant Clock Service. While I refactored Services/Cron I once again stumbled upon time() and date(), which caused issues due to wrong usage/wrong assumptions when dealing with now (time() relies on January 1 1970 00:00:00 GMT which is more or less UTC, date() always relies on date_default_timezone_set(), this MUST NOT be mixed when storing now information or doing arithmetics when retrieving a Y-m-d H:i:s back from the persistence layer).
In addition the usage of these functions posseses the same issues like accessing the global scope or other infrastructure without relying on Dependency Injection. Accessing the time or date is just another subtle way of “reaching out”, which makes it hard/impossible to test those methods.
I would like to change this with this PR.

User Land Perspective: See https://github.com/ILIAS-eLearning/ILIAS/pull/4004/files#diff-19ff14f8652abd51b667e794b4258fa8cc58e7845c95af91fbc8ac15f0a41f8aR411

@mjansenDatabay mjansenDatabay added improvement php Pull requests that update Php code labels Feb 5, 2022
@mjansenDatabay mjansenDatabay changed the title Clock: Introduce PSR-20 Clock Service Clock: Introduce PSR-20 Clock Service as src/Data type Feb 8, 2022
@matthiaskunkel
Copy link
Member

Jour Fixe, 07 MAR 2022 : We highly appreciate this suggestion and accept this PR for trunk.

@mjansenDatabay mjansenDatabay force-pushed the feature/8/clock-service branch from cfdbe58 to 8904ae2 Compare March 8, 2022 08:31
@mjansenDatabay mjansenDatabay merged commit d0b2575 into ILIAS-eLearning:trunk Mar 8, 2022
@mjansenDatabay mjansenDatabay deleted the feature/8/clock-service branch January 9, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants